package com.design.patterns.list.iterator;

import com.design.patterns.list.iterator.aggregate.ArtCollege;
import com.design.patterns.list.iterator.aggregate.ComputerCollege;
import com.design.patterns.list.iterator.aggregate.Department;

import java.util.Iterator;

/**
 * @author Wangzhiwen
 */
public class IteratorClient {

    public static void main(String[] args) {
        ComputerCollege computerCollege = new ComputerCollege(3);
        computerCollege.add("11111","1111");
        computerCollege.add("22222","2222");
        computerCollege.add("33333","3333");
        Iterator<Department> iterator = computerCollege.createIterator();
        System.out.println(computerCollege.name());
        while (iterator.hasNext()){
            Department next = iterator.next();
            System.out.println(next);
        }

        ArtCollege artCollege = new ArtCollege(3);
        artCollege.add("+++++","++++");
        artCollege.add("-----","----");
        artCollege.add("%%%%%","%%%%");
        Iterator<Department> artCollegeIterator = artCollege.createIterator();
        System.out.println(artCollege.name());
        while (artCollegeIterator.hasNext()){
            Department next = artCollegeIterator.next();
            System.out.println(next);
        }
    }

}
